home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / lib / python2.4 / locale.py < prev    next >
Encoding:
Python Source  |  2007-04-12  |  69.3 KB  |  1,525 lines

  1. """ Locale support.
  2.  
  3.     The module provides low-level access to the C lib's locale APIs
  4.     and adds high level number formatting APIs as well as a locale
  5.     aliasing engine to complement these.
  6.  
  7.     The aliasing engine includes support for many commonly used locale
  8.     names and maps them to values suitable for passing to the C lib's
  9.     setlocale() function. It also includes default encodings for all
  10.     supported locale names.
  11.  
  12. """
  13.  
  14. import sys
  15.  
  16. # Try importing the _locale module.
  17. #
  18. # If this fails, fall back on a basic 'C' locale emulation.
  19.  
  20. # Yuck:  LC_MESSAGES is non-standard:  can't tell whether it exists before
  21. # trying the import.  So __all__ is also fiddled at the end of the file.
  22. __all__ = ["setlocale","Error","localeconv","strcoll","strxfrm",
  23.            "format","str","atof","atoi","LC_CTYPE","LC_COLLATE",
  24.            "LC_TIME","LC_MONETARY","LC_NUMERIC", "LC_ALL","CHAR_MAX"]
  25.  
  26. try:
  27.  
  28.     from _locale import *
  29.  
  30. except ImportError:
  31.  
  32.     # Locale emulation
  33.  
  34.     CHAR_MAX = 127
  35.     LC_ALL = 6
  36.     LC_COLLATE = 3
  37.     LC_CTYPE = 0
  38.     LC_MESSAGES = 5
  39.     LC_MONETARY = 4
  40.     LC_NUMERIC = 1
  41.     LC_TIME = 2
  42.     Error = ValueError
  43.  
  44.     def localeconv():
  45.         """ localeconv() -> dict.
  46.             Returns numeric and monetary locale-specific parameters.
  47.         """
  48.         # 'C' locale default values
  49.         return {'grouping': [127],
  50.                 'currency_symbol': '',
  51.                 'n_sign_posn': 127,
  52.                 'p_cs_precedes': 127,
  53.                 'n_cs_precedes': 127,
  54.                 'mon_grouping': [],
  55.                 'n_sep_by_space': 127,
  56.                 'decimal_point': '.',
  57.                 'negative_sign': '',
  58.                 'positive_sign': '',
  59.                 'p_sep_by_space': 127,
  60.                 'int_curr_symbol': '',
  61.                 'p_sign_posn': 127,
  62.                 'thousands_sep': '',
  63.                 'mon_thousands_sep': '',
  64.                 'frac_digits': 127,
  65.                 'mon_decimal_point': '',
  66.                 'int_frac_digits': 127}
  67.  
  68.     def setlocale(category, value=None):
  69.         """ setlocale(integer,string=None) -> string.
  70.             Activates/queries locale processing.
  71.         """
  72.         if value not in (None, '', 'C'):
  73.             raise Error, '_locale emulation only supports "C" locale'
  74.         return 'C'
  75.  
  76.     def strcoll(a,b):
  77.         """ strcoll(string,string) -> int.
  78.             Compares two strings according to the locale.
  79.         """
  80.         return cmp(a,b)
  81.  
  82.     def strxfrm(s):
  83.         """ strxfrm(string) -> string.
  84.             Returns a string that behaves for cmp locale-aware.
  85.         """
  86.         return s
  87.  
  88. ### Number formatting APIs
  89.  
  90. # Author: Martin von Loewis
  91.  
  92. #perform the grouping from right to left
  93. def _group(s):
  94.     conv=localeconv()
  95.     grouping=conv['grouping']
  96.     if not grouping:return (s, 0)
  97.     result=""
  98.     seps = 0
  99.     spaces = ""
  100.     if s[-1] == ' ':
  101.         sp = s.find(' ')
  102.         spaces = s[sp:]
  103.         s = s[:sp]
  104.     while s and grouping:
  105.         # if grouping is -1, we are done
  106.         if grouping[0]==CHAR_MAX:
  107.             break
  108.         # 0: re-use last group ad infinitum
  109.         elif grouping[0]!=0:
  110.             #process last group
  111.             group=grouping[0]
  112.             grouping=grouping[1:]
  113.         if result:
  114.             result=s[-group:]+conv['thousands_sep']+result
  115.             seps += 1
  116.         else:
  117.             result=s[-group:]
  118.         s=s[:-group]
  119.         if s and s[-1] not in "0123456789":
  120.             # the leading string is only spaces and signs
  121.             return s+result+spaces,seps
  122.     if not result:
  123.         return s+spaces,seps
  124.     if s:
  125.         result=s+conv['thousands_sep']+result
  126.         seps += 1
  127.     return result+spaces,seps
  128.  
  129. def format(f,val,grouping=0):
  130.     """Formats a value in the same way that the % formatting would use,
  131.     but takes the current locale into account.
  132.     Grouping is applied if the third parameter is true."""
  133.     result = f % val
  134.     fields = result.split(".")
  135.     seps = 0
  136.     if grouping:
  137.         fields[0],seps=_group(fields[0])
  138.     if len(fields)==2:
  139.         result = fields[0]+localeconv()['decimal_point']+fields[1]
  140.     elif len(fields)==1:
  141.         result = fields[0]
  142.     else:
  143.         raise Error, "Too many decimal points in result string"
  144.  
  145.     while seps:
  146.         # If the number was formatted for a specific width, then it
  147.         # might have been filled with spaces to the left or right. If
  148.         # so, kill as much spaces as there where separators.
  149.         # Leading zeroes as fillers are not yet dealt with, as it is
  150.         # not clear how they should interact with grouping.
  151.         sp = result.find(" ")
  152.         if sp==-1:break
  153.         result = result[:sp]+result[sp+1:]
  154.         seps -= 1
  155.  
  156.     return result
  157.  
  158. def str(val):
  159.     """Convert float to integer, taking the locale into account."""
  160.     return format("%.12g",val)
  161.  
  162. def atof(string,func=float):
  163.     "Parses a string as a float according to the locale settings."
  164.     #First, get rid of the grouping
  165.     ts = localeconv()['thousands_sep']
  166.     if ts:
  167.         string = string.replace(ts, '')
  168.     #next, replace the decimal point with a dot
  169.     dd = localeconv()['decimal_point']
  170.     if dd:
  171.         string = string.replace(dd, '.')
  172.     #finally, parse the string
  173.     return func(string)
  174.  
  175. def atoi(str):
  176.     "Converts a string to an integer according to the locale settings."
  177.     return atof(str, int)
  178.  
  179. def _test():
  180.     setlocale(LC_ALL, "")
  181.     #do grouping
  182.     s1=format("%d", 123456789,1)
  183.     print s1, "is", atoi(s1)
  184.     #standard formatting
  185.     s1=str(3.14)
  186.     print s1, "is", atof(s1)
  187.  
  188. ### Locale name aliasing engine
  189.  
  190. # Author: Marc-Andre Lemburg, mal@lemburg.com
  191. # Various tweaks by Fredrik Lundh <fredrik@pythonware.com>
  192.  
  193. # store away the low-level version of setlocale (it's
  194. # overridden below)
  195. _setlocale = setlocale
  196.  
  197. def normalize(localename):
  198.  
  199.     """ Returns a normalized locale code for the given locale
  200.         name.
  201.  
  202.         The returned locale code is formatted for use with
  203.         setlocale().
  204.  
  205.         If normalization fails, the original name is returned
  206.         unchanged.
  207.  
  208.         If the given encoding is not known, the function defaults to
  209.         the default encoding for the locale code just like setlocale()
  210.         does.
  211.  
  212.     """
  213.     # Normalize the locale name and extract the encoding
  214.     fullname = localename.lower()
  215.     if ':' in fullname:
  216.         # ':' is sometimes used as encoding delimiter.
  217.         fullname = fullname.replace(':', '.')
  218.     if '.' in fullname:
  219.         langname, encoding = fullname.split('.')[:2]
  220.         fullname = langname + '.' + encoding
  221.     else:
  222.         langname = fullname
  223.         encoding = ''
  224.  
  225.     # First lookup: fullname (possibly with encoding)
  226.     code = locale_alias.get(fullname, None)
  227.     if code is not None:
  228.         return code
  229.  
  230.     # Second try: langname (without encoding)
  231.     code = locale_alias.get(langname, None)
  232.     if code is not None:
  233.         if '.' in code:
  234.             langname, defenc = code.split('.')
  235.         else:
  236.             langname = code
  237.             defenc = ''
  238.         if encoding:
  239.             encoding = encoding_alias.get(encoding, encoding)
  240.         else:
  241.             encoding = defenc
  242.         if encoding:
  243.             return langname + '.' + encoding
  244.         else:
  245.             return langname
  246.  
  247.     else:
  248.         return localename
  249.  
  250. def _parse_localename(localename):
  251.  
  252.     """ Parses the locale code for localename and returns the
  253.         result as tuple (language code, encoding).
  254.  
  255.         The localename is normalized and passed through the locale
  256.         alias engine. A ValueError is raised in case the locale name
  257.         cannot be parsed.
  258.  
  259.         The language code corresponds to RFC 1766.  code and encoding
  260.         can be None in case the values cannot be determined or are
  261.         unknown to this implementation.
  262.  
  263.     """
  264.     code = normalize(localename)
  265.     if '@' in code:
  266.         # Deal with locale modifiers
  267.         code, modifier = code.split('@')
  268.         if modifier == 'euro' and '.' not in code:
  269.             # Assume Latin-9 for @euro locales. This is bogus,
  270.             # since some systems may use other encodings for these
  271.             # locales. Also, we ignore other modifiers.
  272.             return code, 'iso-8859-15'
  273.  
  274.     if '.' in code:
  275.         return tuple(code.split('.')[:2])
  276.     elif code == 'C':
  277.         return None, None
  278.     raise ValueError, 'unknown locale: %s' % localename
  279.  
  280. def _build_localename(localetuple):
  281.  
  282.     """ Builds a locale code from the given tuple (language code,
  283.         encoding).
  284.  
  285.         No aliasing or normalizing takes place.
  286.  
  287.     """
  288.     language, encoding = localetuple
  289.     if language is None:
  290.         language = 'C'
  291.     if encoding is None:
  292.         return language
  293.     else:
  294.         return language + '.' + encoding
  295.  
  296. def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
  297.  
  298.     """ Tries to determine the default locale settings and returns
  299.         them as tuple (language code, encoding).
  300.  
  301.         According to POSIX, a program which has not called
  302.         setlocale(LC_ALL, "") runs using the portable 'C' locale.
  303.         Calling setlocale(LC_ALL, "") lets it use the default locale as
  304.         defined by the LANG variable. Since we don't want to interfere
  305.         with the current locale setting we thus emulate the behavior
  306.         in the way described above.
  307.  
  308.         To maintain compatibility with other platforms, not only the
  309.         LANG variable is tested, but a list of variables given as
  310.         envvars parameter. The first found to be defined will be
  311.         used. envvars defaults to the search path used in GNU gettext;
  312.         it must always contain the variable name 'LANG'.
  313.  
  314.         Except for the code 'C', the language code corresponds to RFC
  315.         1766.  code and encoding can be None in case the values cannot
  316.         be determined.
  317.  
  318.     """
  319.  
  320.     try:
  321.         # check if it's supported by the _locale module
  322.         import _locale
  323.         code, encoding = _locale._getdefaultlocale()
  324.     except (ImportError, AttributeError):
  325.         pass
  326.     else:
  327.         # make sure the code/encoding values are valid
  328.         if sys.platform == "win32" and code and code[:2] == "0x":
  329.             # map windows language identifier to language name
  330.             code = windows_locale.get(int(code, 0))
  331.         # ...add other platform-specific processing here, if
  332.         # necessary...
  333.         return code, encoding
  334.  
  335.     # fall back on POSIX behaviour
  336.     import os
  337.     lookup = os.environ.get
  338.     for variable in envvars:
  339.         localename = lookup(variable,None)
  340.         if localename:
  341.             if variable == 'LANGUAGE':
  342.                 localename = localename.split(':')[0]
  343.             break
  344.     else:
  345.         localename = 'C'
  346.     return _parse_localename(localename)
  347.  
  348.  
  349. def getlocale(category=LC_CTYPE):
  350.  
  351.     """ Returns the current setting for the given locale category as
  352.         tuple (language code, encoding).
  353.  
  354.         category may be one of the LC_* value except LC_ALL. It
  355.         defaults to LC_CTYPE.
  356.  
  357.         Except for the code 'C', the language code corresponds to RFC
  358.         1766.  code and encoding can be None in case the values cannot
  359.         be determined.
  360.  
  361.     """
  362.     localename = _setlocale(category)
  363.     if category == LC_ALL and ';' in localename:
  364.         raise TypeError, 'category LC_ALL is not supported'
  365.     return _parse_localename(localename)
  366.  
  367. def setlocale(category, locale=None):
  368.  
  369.     """ Set the locale for the given category.  The locale can be
  370.         a string, a locale tuple (language code, encoding), or None.
  371.  
  372.         Locale tuples are converted to strings the locale aliasing
  373.         engine.  Locale strings are passed directly to the C lib.
  374.  
  375.         category may be given as one of the LC_* values.
  376.  
  377.     """
  378.     if locale and type(locale) is not type(""):
  379.         # convert to string
  380.         locale = normalize(_build_localename(locale))
  381.     return _setlocale(category, locale)
  382.  
  383. def resetlocale(category=LC_ALL):
  384.  
  385.     """ Sets the locale for category to the default setting.
  386.  
  387.         The default setting is determined by calling
  388.         getdefaultlocale(). category defaults to LC_ALL.
  389.  
  390.     """
  391.     _setlocale(category, _build_localename(getdefaultlocale()))
  392.  
  393. if sys.platform in ('win32', 'darwin', 'mac'):
  394.     # On Win32, this will return the ANSI code page
  395.     # On the Mac, it should return the system encoding;
  396.     # it might return "ascii" instead
  397.     def getpreferredencoding(do_setlocale = True):
  398.         """Return the charset that the user is likely using."""
  399.         import _locale
  400.         return _locale._getdefaultlocale()[1]
  401. else:
  402.     # On Unix, if CODESET is available, use that.
  403.     try:
  404.         CODESET
  405.     except NameError:
  406.         # Fall back to parsing environment variables :-(
  407.         def getpreferredencoding(do_setlocale = True):
  408.             """Return the charset that the user is likely using,
  409.             by looking at environment variables."""
  410.             return getdefaultlocale()[1]
  411.     else:
  412.         def getpreferredencoding(do_setlocale = True):
  413.             """Return the charset that the user is likely using,
  414.             according to the system configuration."""
  415.             if do_setlocale:
  416.                 oldloc = setlocale(LC_CTYPE)
  417.                 setlocale(LC_CTYPE, "")
  418.                 result = nl_langinfo(CODESET)
  419.                 setlocale(LC_CTYPE, oldloc)
  420.                 return result
  421.             else:
  422.                 return nl_langinfo(CODESET)
  423.  
  424.  
  425. ### Database
  426. #
  427. # The following data was extracted from the locale.alias file which
  428. # comes with X11 and then hand edited removing the explicit encoding
  429. # definitions and adding some more aliases. The file is usually
  430. # available as /usr/share/X11/locale/locale.alias.
  431. #
  432.  
  433. #
  434. # The encoding_alias table maps lowercase encoding alias names to C
  435. # locale encoding names (case-sensitive).
  436. #
  437. encoding_alias = {
  438.         '437':                          'C',
  439.         'c':                            'C',
  440.         'iso8859':                      'ISO8859-1',
  441.         '8859':                         'ISO8859-1',
  442.         '88591':                        'ISO8859-1',
  443.         'ascii':                        'ISO8859-1',
  444.         'en':                           'ISO8859-1',
  445.         'iso88591':                     'ISO8859-1',
  446.         'iso_8859-1':                   'ISO8859-1',
  447.         '885915':                       'ISO8859-15',
  448.         'iso885915':                    'ISO8859-15',
  449.         'iso_8859-15':                  'ISO8859-15',
  450.         'iso8859-2':                    'ISO8859-2',
  451.         'iso88592':                     'ISO8859-2',
  452.         'iso_8859-2':                   'ISO8859-2',
  453.         'iso88595':                     'ISO8859-5',
  454.         'iso88596':                     'ISO8859-6',
  455.         'iso88597':                     'ISO8859-7',
  456.         'iso88598':                     'ISO8859-8',
  457.         'iso88599':                     'ISO8859-9',
  458.         'iso-2022-jp':                  'JIS7',
  459.         'jis':                          'JIS7',
  460.         'jis7':                         'JIS7',
  461.         'sjis':                         'SJIS',
  462.         'tis620':                       'TACTIS',
  463.         'ajec':                         'eucJP',
  464.         'eucjp':                        'eucJP',
  465.         'ujis':                         'eucJP',
  466.         'utf':                          'utf-8',
  467.         'utf8':                         'utf-8',
  468.         'utf8@ucs4':                    'utf-8',
  469. }
  470.  
  471. #
  472. # The locale_alias table maps lowercase alias names to C locale names
  473. # (case-sensitive). Encodings are always separated from the locale
  474. # name using a dot ('.'); they should only be given in case the
  475. # language name is needed to interpret the given encoding alias
  476. # correctly (CJK codes often have this need).
  477. #
  478. # table updated from /usr/share/X11/locale/locale.alias (Ubuntu/Debian)
  479. #
  480. #    updated 'bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
  481. #    updated 'bg_bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
  482. #    updated 'bulgarian' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
  483. #    updated 'cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
  484. #    updated 'cz_cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
  485. #    updated 'czech' -> 'cs_CS.ISO8859-2' to 'cs_CZ.ISO8859-2'
  486. #    updated 'dutch' -> 'nl_BE.ISO8859-1' to 'nl_NL.ISO8859-1'
  487. #    updated 'et' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
  488. #    updated 'et_ee' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
  489. #    updated 'fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
  490. #    updated 'fi_fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
  491. #    updated 'iw' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
  492. #    updated 'iw_il' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
  493. #    updated 'japanese' -> 'ja_JP.SJIS' to 'ja_JP.eucJP'
  494. #    updated 'lt' -> 'lt_LT.ISO8859-4' to 'lt_LT.ISO8859-13'
  495. #    updated 'lv' -> 'lv_LV.ISO8859-4' to 'lv_LV.ISO8859-13'
  496. #    updated 'sl' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
  497. #    updated 'slovene' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
  498. #    updated 'th_th' -> 'th_TH.TACTIS' to 'th_TH.ISO8859-11'
  499. #    updated 'xh' -> 'xh_ZH.ISO8859-1' to 'xh_ZA.ISO8859-1'
  500. #    updated 'xh_za' -> 'xh_ZH.ISO8859-1' to 'xh_ZA.ISO8859-1'
  501. #    updated 'zh_cn' -> 'zh_CN.eucCN' to 'zh_CN.gb2312'
  502. #    updated 'zh_cn.big5' -> 'zh_TW.eucTW' to 'zh_TW.big5'
  503. #    updated 'zh_tw' -> 'zh_TW.eucTW' to 'zh_TW.big5'
  504.  
  505. locale_alias = {
  506.         'a3':                            'a3_AZ.KOI8-C',
  507.         'a3_az':                         'a3_AZ.KOI8-C',
  508.         'a3_az.koi8c':                   'a3_AZ.KOI8-C',
  509.         'af':                            'af_ZA.ISO8859-1',
  510.         'af_za':                         'af_ZA.ISO8859-1',
  511.         'af_za.iso88591':                'af_ZA.ISO8859-1',
  512.         'am':                            'am_ET.UTF-8',
  513.         'am_et':                         'am_ET.UTF-8',
  514.         'american':                      'en_US.ISO8859-1',
  515.         'american.iso88591':             'en_US.ISO8859-1',
  516.         'ar':                            'ar_AA.ISO8859-6',
  517.         'ar_aa':                         'ar_AA.ISO8859-6',
  518.         'ar_aa.iso88596':                'ar_AA.ISO8859-6',
  519.         'ar_ae':                         'ar_AE.ISO8859-6',
  520.         'ar_ae.iso88596':                'ar_AE.ISO8859-6',
  521.         'ar_bh':                         'ar_BH.ISO8859-6',
  522.         'ar_bh.iso88596':                'ar_BH.ISO8859-6',
  523.         'ar_dz':                         'ar_DZ.ISO8859-6',
  524.         'ar_dz.iso88596':                'ar_DZ.ISO8859-6',
  525.         'ar_eg':                         'ar_EG.ISO8859-6',
  526.         'ar_eg.iso88596':                'ar_EG.ISO8859-6',
  527.         'ar_iq':                         'ar_IQ.ISO8859-6',
  528.         'ar_iq.iso88596':                'ar_IQ.ISO8859-6',
  529.         'ar_jo':                         'ar_JO.ISO8859-6',
  530.         'ar_jo.iso88596':                'ar_JO.ISO8859-6',
  531.         'ar_kw':                         'ar_KW.ISO8859-6',
  532.         'ar_kw.iso88596':                'ar_KW.ISO8859-6',
  533.         'ar_lb':                         'ar_LB.ISO8859-6',
  534.         'ar_lb.iso88596':                'ar_LB.ISO8859-6',
  535.         'ar_ly':                         'ar_LY.ISO8859-6',
  536.         'ar_ly.iso88596':                'ar_LY.ISO8859-6',
  537.         'ar_ma':                         'ar_MA.ISO8859-6',
  538.         'ar_ma.iso88596':                'ar_MA.ISO8859-6',
  539.         'ar_om':                         'ar_OM.ISO8859-6',
  540.         'ar_om.iso88596':                'ar_OM.ISO8859-6',
  541.         'ar_qa':                         'ar_QA.ISO8859-6',
  542.         'ar_qa.iso88596':                'ar_QA.ISO8859-6',
  543.         'ar_sa':                         'ar_SA.ISO8859-6',
  544.         'ar_sa.iso88596':                'ar_SA.ISO8859-6',
  545.         'ar_sd':                         'ar_SD.ISO8859-6',
  546.         'ar_sd.iso88596':                'ar_SD.ISO8859-6',
  547.         'ar_sy':                         'ar_SY.ISO8859-6',
  548.         'ar_sy.iso88596':                'ar_SY.ISO8859-6',
  549.         'ar_tn':                         'ar_TN.ISO8859-6',
  550.         'ar_tn.iso88596':                'ar_TN.ISO8859-6',
  551.         'ar_ye':                         'ar_YE.ISO8859-6',
  552.         'ar_ye.iso88596':                'ar_YE.ISO8859-6',
  553.         'arabic':                        'ar_AA.ISO8859-6',
  554.         'arabic.iso88596':               'ar_AA.ISO8859-6',
  555.         'az':                            'az_AZ.ISO8859-9E',
  556.         'az_az':                         'az_AZ.ISO8859-9E',
  557.         'az_az.iso88599e':               'az_AZ.ISO8859-9E',
  558.         'be':                            'be_BY.CP1251',
  559.         'be_by':                         'be_BY.CP1251',
  560.         'be_by.cp1251':                  'be_BY.CP1251',
  561.         'be_by.microsoftcp1251':         'be_BY.CP1251',
  562.         'bg':                            'bg_BG.CP1251',
  563.         'bg_bg':                         'bg_BG.CP1251',
  564.         'bg_bg.cp1251':                  'bg_BG.CP1251',
  565.         'bg_bg.iso88595':                'bg_BG.ISO8859-5',
  566.         'bg_bg.koi8r':                   'bg_BG.KOI8-R',
  567.         'bg_bg.microsoftcp1251':         'bg_BG.CP1251',
  568.         'bokmal':                        'nb_NO.ISO8859-1',
  569.         'bokm\xe5l':                     'nb_NO.ISO8859-1',
  570.         'br':                            'br_FR.ISO8859-1',
  571.         'br_fr':                         'br_FR.ISO8859-1',
  572.         'br_fr.iso88591':                'br_FR.ISO8859-1',
  573.         'br_fr.iso885914':               'br_FR.ISO8859-14',
  574.         'br_fr.iso885915':               'br_FR.ISO8859-15',
  575.         'br_fr.iso885915@euro':          'br_FR.ISO8859-15',
  576.         'br_fr.utf8@euro':               'br_FR.UTF-8',
  577.         'br_fr@euro':                    'br_FR.ISO8859-15',
  578.         'bs':                            'bs_BA.ISO8859-2',
  579.         'bs_ba':                         'bs_BA.ISO8859-2',
  580.         'bs_ba.iso88592':                'bs_BA.ISO8859-2',
  581.         'bulgarian':                     'bg_BG.CP1251',
  582.         'c':                             'C',
  583.         'c-french':                      'fr_CA.ISO8859-1',
  584.         'c-french.iso88591':             'fr_CA.ISO8859-1',
  585.         'c.en':                          'C',
  586.         'c.iso88591':                    'en_US.ISO8859-1',
  587.         'c_c':                           'C',
  588.         'c_c.c':                         'C',
  589.         'ca':                            'ca_ES.ISO8859-1',
  590.         'ca_es':                         'ca_ES.ISO8859-1',
  591.         'ca_es.iso88591':                'ca_ES.ISO8859-1',
  592.         'ca_es.iso885915':               'ca_ES.ISO8859-15',
  593.         'ca_es.iso885915@euro':          'ca_ES.ISO8859-15',
  594.         'ca_es.utf8@euro':               'ca_ES.UTF-8',
  595.         'ca_es@euro':                    'ca_ES.ISO8859-15',
  596.         'catalan':                       'ca_ES.ISO8859-1',
  597.         'cextend':                       'en_US.ISO8859-1',
  598.         'cextend.en':                    'en_US.ISO8859-1',
  599.         'chinese-s':                     'zh_CN.eucCN',
  600.         'chinese-t':                     'zh_TW.eucTW',
  601.         'croatian':                      'hr_HR.ISO8859-2',
  602.         'cs':                            'cs_CZ.ISO8859-2',
  603.         'cs_cs':                         'cs_CZ.ISO8859-2',
  604.         'cs_cs.iso88592':                'cs_CZ.ISO8859-2',
  605.         'cs_cz':                         'cs_CZ.ISO8859-2',
  606.         'cs_cz.iso88592':                'cs_CZ.ISO8859-2',
  607.         'cy':                            'cy_GB.ISO8859-1',
  608.         'cy_gb':                         'cy_GB.ISO8859-1',
  609.         'cy_gb.iso88591':                'cy_GB.ISO8859-1',
  610.         'cy_gb.iso885914':               'cy_GB.ISO8859-14',
  611.         'cy_gb.iso885915':               'cy_GB.ISO8859-15',
  612.         'cz':                            'cs_CZ.ISO8859-2',
  613.         'cz_cz':                         'cs_CZ.ISO8859-2',
  614.         'czech':                         'cs_CZ.ISO8859-2',
  615.         'da':                            'da_DK.ISO8859-1',
  616.         'da_dk':                         'da_DK.ISO8859-1',
  617.         'da_dk.88591':                   'da_DK.ISO8859-1',
  618.         'da_dk.885915':                  'da_DK.ISO8859-15',
  619.         'da_dk.iso88591':                'da_DK.ISO8859-1',
  620.         'da_dk.iso885915':               'da_DK.ISO8859-15',
  621.         'danish':                        'da_DK.ISO8859-1',
  622.         'danish.iso88591':               'da_DK.ISO8859-1',
  623.         'dansk':                         'da_DK.ISO8859-1',
  624.         'de':                            'de_DE.ISO8859-1',
  625.         'de_at':                         'de_AT.ISO8859-1',
  626.         'de_at.iso88591':                'de_AT.ISO8859-1',
  627.         'de_at.iso885915':               'de_AT.ISO8859-15',
  628.         'de_at.iso885915@euro':          'de_AT.ISO8859-15',
  629.         'de_at.utf8@euro':               'de_AT.UTF-8',
  630.         'de_at@euro':                    'de_AT.ISO8859-15',
  631.         'de_be':                         'de_BE.ISO8859-1',
  632.         'de_be.iso88591':                'de_BE.ISO8859-1',
  633.         'de_be.iso885915':               'de_BE.ISO8859-15',
  634.         'de_be.iso885915@euro':          'de_BE.ISO8859-15',
  635.         'de_be.utf8@euro':               'de_BE.UTF-8',
  636.         'de_be@euro':                    'de_BE.ISO8859-15',
  637.         'de_ch':                         'de_CH.ISO8859-1',
  638.         'de_ch.iso88591':                'de_CH.ISO8859-1',
  639.         'de_ch.iso885915':               'de_CH.ISO8859-15',
  640.         'de_de':                         'de_DE.ISO8859-1',
  641.         'de_de.88591':                   'de_DE.ISO8859-1',
  642.         'de_de.885915':                  'de_DE.ISO8859-15',
  643.         'de_de.885915@euro':             'de_DE.ISO8859-15',
  644.         'de_de.iso88591':                'de_DE.ISO8859-1',
  645.         'de_de.iso885915':               'de_DE.ISO8859-15',
  646.         'de_de.iso885915@euro':          'de_DE.ISO8859-15',
  647.         'de_de.utf8@euro':               'de_DE.UTF-8',
  648.         'de_de@euro':                    'de_DE.ISO8859-15',
  649.         'de_lu':                         'de_LU.ISO8859-1',
  650.         'de_lu.iso88591':                'de_LU.ISO8859-1',
  651.         'de_lu.iso885915':               'de_LU.ISO8859-15',
  652.         'de_lu.iso885915@euro':          'de_LU.ISO8859-15',
  653.         'de_lu.utf8@euro':               'de_LU.UTF-8',
  654.         'de_lu@euro':                    'de_LU.ISO8859-15',
  655.         'deutsch':                       'de_DE.ISO8859-1',
  656.         'dutch':                         'nl_NL.ISO8859-1',
  657.         'dutch.iso88591':                'nl_BE.ISO8859-1',
  658.         'ee':                            'ee_EE.ISO8859-4',
  659.         'ee_ee':                         'ee_EE.ISO8859-4',
  660.         'ee_ee.iso88594':                'ee_EE.ISO8859-4',
  661.         'eesti':                         'et_EE.ISO8859-1',
  662.         'el':                            'el_GR.ISO8859-7',
  663.         'el_gr':                         'el_GR.ISO8859-7',
  664.         'el_gr.iso88597':                'el_GR.ISO8859-7',
  665.         'el_gr@euro':                    'el_GR.ISO8859-15',
  666.         'en':                            'en_US.ISO8859-1',
  667.         'en.iso88591':                   'en_US.ISO8859-1',
  668.         'en_au':                         'en_AU.ISO8859-1',
  669.         'en_au.iso88591':                'en_AU.ISO8859-1',
  670.         'en_be':                         'en_BE.ISO8859-1',
  671.         'en_be@euro':                    'en_BE.ISO8859-15',
  672.         'en_bw':                         'en_BW.ISO8859-1',
  673.         'en_bw.iso88591':                'en_BW.ISO8859-1',
  674.         'en_ca':                         'en_CA.ISO8859-1',
  675.         'en_ca.iso88591':                'en_CA.ISO8859-1',
  676.         'en_gb':                         'en_GB.ISO8859-1',
  677.         'en_gb.88591':                   'en_GB.ISO8859-1',
  678.         'en_gb.iso88591':                'en_GB.ISO8859-1',
  679.         'en_gb.iso885915':               'en_GB.ISO8859-15',
  680.         'en_hk':                         'en_HK.ISO8859-1',
  681.         'en_hk.iso88591':                'en_HK.ISO8859-1',
  682.         'en_ie':                         'en_IE.ISO8859-1',
  683.         'en_ie.iso88591':                'en_IE.ISO8859-1',
  684.         'en_ie.iso885915':               'en_IE.ISO8859-15',
  685.         'en_ie.iso885915@euro':          'en_IE.ISO8859-15',
  686.         'en_ie.utf8@euro':               'en_IE.UTF-8',
  687.         'en_ie@euro':                    'en_IE.ISO8859-15',
  688.         'en_in':                         'en_IN.ISO8859-1',
  689.         'en_nz':                         'en_NZ.ISO8859-1',
  690.         'en_nz.iso88591':                'en_NZ.ISO8859-1',
  691.         'en_ph':                         'en_PH.ISO8859-1',
  692.         'en_ph.iso88591':                'en_PH.ISO8859-1',
  693.         'en_sg':                         'en_SG.ISO8859-1',
  694.         'en_sg.iso88591':                'en_SG.ISO8859-1',
  695.         'en_uk':                         'en_GB.ISO8859-1',
  696.         'en_us':                         'en_US.ISO8859-1',
  697.         'en_us.88591':                   'en_US.ISO8859-1',
  698.         'en_us.885915':                  'en_US.ISO8859-15',
  699.         'en_us.iso88591':                'en_US.ISO8859-1',
  700.         'en_us.iso885915':               'en_US.ISO8859-15',
  701.         'en_us.iso885915@euro':          'en_US.ISO8859-15',
  702.         'en_za':                         'en_ZA.ISO8859-1',
  703.         'en_za.88591':                   'en_ZA.ISO8859-1',
  704.         'en_za.iso88591':                'en_ZA.ISO8859-1',
  705.         'en_za.iso885915':               'en_ZA.ISO8859-15',
  706.         'en_zw':                         'en_ZW.ISO8859-1',
  707.         'en_zw.iso88591':                'en_ZW.ISO8859-1',
  708.         'eng_gb':                        'en_GB.ISO8859-1',
  709.         'eng_gb.8859':                   'en_GB.ISO8859-1',
  710.         'english':                       'en_EN.ISO8859-1',
  711.         'english.iso88591':              'en_EN.ISO8859-1',
  712.         'english_uk':                    'en_GB.ISO8859-1',
  713.         'english_uk.8859':               'en_GB.ISO8859-1',
  714.         'english_united-states':         'en_US.ISO8859-1',
  715.         'english_united-states.437':     'C',
  716.         'english_us':                    'en_US.ISO8859-1',
  717.         'english_us.8859':               'en_US.ISO8859-1',
  718.         'english_us.ascii':              'en_US.ISO8859-1',
  719.         'eo':                            'eo_XX.ISO8859-3',
  720.         'eo_eo':                         'eo_EO.ISO8859-3',
  721.         'eo_eo.iso88593':                'eo_EO.ISO8859-3',
  722.         'eo_xx':                         'eo_XX.ISO8859-3',
  723.         'eo_xx.iso88593':                'eo_XX.ISO8859-3',
  724.         'es':                            'es_ES.ISO8859-1',
  725.         'es_ar':                         'es_AR.ISO8859-1',
  726.         'es_ar.iso88591':                'es_AR.ISO8859-1',
  727.         'es_bo':                         'es_BO.ISO8859-1',
  728.         'es_bo.iso88591':                'es_BO.ISO8859-1',
  729.         'es_cl':                         'es_CL.ISO8859-1',
  730.         'es_cl.iso88591':                'es_CL.ISO8859-1',
  731.         'es_co':                         'es_CO.ISO8859-1',
  732.         'es_co.iso88591':                'es_CO.ISO8859-1',
  733.         'es_cr':                         'es_CR.ISO8859-1',
  734.         'es_cr.iso88591':                'es_CR.ISO8859-1',
  735.         'es_do':                         'es_DO.ISO8859-1',
  736.         'es_do.iso88591':                'es_DO.ISO8859-1',
  737.         'es_ec':                         'es_EC.ISO8859-1',
  738.         'es_ec.iso88591':                'es_EC.ISO8859-1',
  739.         'es_es':                         'es_ES.ISO8859-1',
  740.         'es_es.88591':                   'es_ES.ISO8859-1',
  741.         'es_es.iso88591':                'es_ES.ISO8859-1',
  742.         'es_es.iso885915':               'es_ES.ISO8859-15',
  743.         'es_es.iso885915@euro':          'es_ES.ISO8859-15',
  744.         'es_es.utf8@euro':               'es_ES.UTF-8',
  745.         'es_es@euro':                    'es_ES.ISO8859-15',
  746.         'es_gt':                         'es_GT.ISO8859-1',
  747.         'es_gt.iso88591':                'es_GT.ISO8859-1',
  748.         'es_hn':                         'es_HN.ISO8859-1',
  749.         'es_hn.iso88591':                'es_HN.ISO8859-1',
  750.         'es_mx':                         'es_MX.ISO8859-1',
  751.         'es_mx.iso88591':                'es_MX.ISO8859-1',
  752.         'es_ni':                         'es_NI.ISO8859-1',
  753.         'es_ni.iso88591':                'es_NI.ISO8859-1',
  754.         'es_pa':                         'es_PA.ISO8859-1',
  755.         'es_pa.iso88591':                'es_PA.ISO8859-1',
  756.         'es_pa.iso885915':               'es_PA.ISO8859-15',
  757.         'es_pe':                         'es_PE.ISO8859-1',
  758.         'es_pe.iso88591':                'es_PE.ISO8859-1',
  759.         'es_pe.iso885915':               'es_PE.ISO8859-15',
  760.         'es_pr':                         'es_PR.ISO8859-1',
  761.         'es_pr.iso88591':                'es_PR.ISO8859-1',
  762.         'es_py':                         'es_PY.ISO8859-1',
  763.         'es_py.iso88591':                'es_PY.ISO8859-1',
  764.         'es_py.iso885915':               'es_PY.ISO8859-15',
  765.         'es_sv':                         'es_SV.ISO8859-1',
  766.         'es_sv.iso88591':                'es_SV.ISO8859-1',
  767.         'es_sv.iso885915':               'es_SV.ISO8859-15',
  768.         'es_us':                         'es_US.ISO8859-1',
  769.         'es_us.iso88591':                'es_US.ISO8859-1',
  770.         'es_uy':                         'es_UY.ISO8859-1',
  771.         'es_uy.iso88591':                'es_UY.ISO8859-1',
  772.         'es_uy.iso885915':               'es_UY.ISO8859-15',
  773.         'es_ve':                         'es_VE.ISO8859-1',
  774.         'es_ve.iso88591':                'es_VE.ISO8859-1',
  775.         'es_ve.iso885915':               'es_VE.ISO8859-15',
  776.         'estonian':                      'et_EE.ISO8859-1',
  777.         'et':                            'et_EE.ISO8859-15',
  778.         'et_ee':                         'et_EE.ISO8859-15',
  779.         'et_ee.iso88591':                'et_EE.ISO8859-1',
  780.         'et_ee.iso885913':               'et_EE.ISO8859-13',
  781.         'et_ee.iso885915':               'et_EE.ISO8859-15',
  782.         'et_ee.iso88594':                'et_EE.ISO8859-4',
  783.         'eu':                            'eu_ES.ISO8859-1',
  784.         'eu_es':                         'eu_ES.ISO8859-1',
  785.         'eu_es.iso88591':                'eu_ES.ISO8859-1',
  786.         'eu_es.iso885915':               'eu_ES.ISO8859-15',
  787.         'eu_es.iso885915@euro':          'eu_ES.ISO8859-15',
  788.         'eu_es.utf8@euro':               'eu_ES.UTF-8',
  789.         'eu_es@euro':                    'eu_ES.ISO8859-15',
  790.         'fa':                            'fa_IR.UTF-8',
  791.         'fa_ir':                         'fa_IR.UTF-8',
  792.         'fa_ir.isiri3342':               'fa_IR.ISIRI-3342',
  793.         'fi':                            'fi_FI.ISO8859-15',
  794.         'fi_fi':                         'fi_FI.ISO8859-15',
  795.         'fi_fi.88591':                   'fi_FI.ISO8859-1',
  796.         'fi_fi.iso88591':                'fi_FI.ISO8859-1',
  797.         'fi_fi.iso885915':               'fi_FI.ISO8859-15',
  798.         'fi_fi.iso885915@euro':          'fi_FI.ISO8859-15',
  799.         'fi_fi.utf8@euro':               'fi_FI.UTF-8',
  800.         'fi_fi@euro':                    'fi_FI.ISO8859-15',
  801.         'finnish':                       'fi_FI.ISO8859-1',
  802.         'finnish.iso88591':              'fi_FI.ISO8859-1',
  803.         'fo':                            'fo_FO.ISO8859-1',
  804.         'fo_fo':                         'fo_FO.ISO8859-1',
  805.         'fo_fo.iso88591':                'fo_FO.ISO8859-1',
  806.         'fo_fo.iso885915':               'fo_FO.ISO8859-15',
  807.         'fr':                            'fr_FR.ISO8859-1',
  808.         'fr_be':                         'fr_BE.ISO8859-1',
  809.         'fr_be.88591':                   'fr_BE.ISO8859-1',
  810.         'fr_be.iso88591':                'fr_BE.ISO8859-1',
  811.         'fr_be.iso885915':               'fr_BE.ISO8859-15',
  812.         'fr_be.iso885915@euro':          'fr_BE.ISO8859-15',
  813.         'fr_be.utf8@euro':               'fr_BE.UTF-8',
  814.         'fr_be@euro':                    'fr_BE.ISO8859-15',
  815.         'fr_ca':                         'fr_CA.ISO8859-1',
  816.         'fr_ca.88591':                   'fr_CA.ISO8859-1',
  817.         'fr_ca.iso88591':                'fr_CA.ISO8859-1',
  818.         'fr_ca.iso885915':               'fr_CA.ISO8859-15',
  819.         'fr_ch':                         'fr_CH.ISO8859-1',
  820.         'fr_ch.88591':                   'fr_CH.ISO8859-1',
  821.         'fr_ch.iso88591':                'fr_CH.ISO8859-1',
  822.         'fr_ch.iso885915':               'fr_CH.ISO8859-15',
  823.         'fr_fr':                         'fr_FR.ISO8859-1',
  824.         'fr_fr.88591':                   'fr_FR.ISO8859-1',
  825.         'fr_fr.iso88591':                'fr_FR.ISO8859-1',
  826.         'fr_fr.iso885915':               'fr_FR.ISO8859-15',
  827.         'fr_fr.iso885915@euro':          'fr_FR.ISO8859-15',
  828.         'fr_fr.utf8@euro':               'fr_FR.UTF-8',
  829.         'fr_fr@euro':                    'fr_FR.ISO8859-15',
  830.         'fr_lu':                         'fr_LU.ISO8859-1',
  831.         'fr_lu.88591':                   'fr_LU.ISO8859-1',
  832.         'fr_lu.iso88591':                'fr_LU.ISO8859-1',
  833.         'fr_lu.iso885915':               'fr_LU.ISO8859-15',
  834.         'fr_lu.iso885915@euro':          'fr_LU.ISO8859-15',
  835.         'fr_lu.utf8@euro':               'fr_LU.UTF-8',
  836.         'fr_lu@euro':                    'fr_LU.ISO8859-15',
  837.         'fran\xe7ais':                   'fr_FR.ISO8859-1',
  838.         'fre_fr':                        'fr_FR.ISO8859-1',
  839.         'fre_fr.8859':                   'fr_FR.ISO8859-1',
  840.         'french':                        'fr_FR.ISO8859-1',
  841.         'french.iso88591':               'fr_CH.ISO8859-1',
  842.         'french_france':                 'fr_FR.ISO8859-1',
  843.         'french_france.8859':            'fr_FR.ISO8859-1',
  844.         'ga':                            'ga_IE.ISO8859-1',
  845.         'ga_ie':                         'ga_IE.ISO8859-1',
  846.         'ga_ie.iso88591':                'ga_IE.ISO8859-1',
  847.         'ga_ie.iso885914':               'ga_IE.ISO8859-14',
  848.         'ga_ie.iso885915':               'ga_IE.ISO8859-15',
  849.         'ga_ie.iso885915@euro':          'ga_IE.ISO8859-15',
  850.         'ga_ie.utf8@euro':               'ga_IE.UTF-8',
  851.         'ga_ie@euro':                    'ga_IE.ISO8859-15',
  852.         'galego':                        'gl_ES.ISO8859-1',
  853.         'galician':                      'gl_ES.ISO8859-1',
  854.         'gd':                            'gd_GB.ISO8859-1',
  855.         'gd_gb':                         'gd_GB.ISO8859-1',
  856.         'gd_gb.iso88591':                'gd_GB.ISO8859-1',
  857.         'gd_gb.iso885914':               'gd_GB.ISO8859-14',
  858.         'gd_gb.iso885915':               'gd_GB.ISO8859-15',
  859.         'ger_de':                        'de_DE.ISO8859-1',
  860.         'ger_de.8859':                   'de_DE.ISO8859-1',
  861.         'german':                        'de_DE.ISO8859-1',
  862.         'german.iso88591':               'de_CH.ISO8859-1',
  863.         'german_germany':                'de_DE.ISO8859-1',
  864.         'german_germany.8859':           'de_DE.ISO8859-1',
  865.         'gl':                            'gl_ES.ISO8859-1',
  866.         'gl_es':                         'gl_ES.ISO8859-1',
  867.         'gl_es.iso88591':                'gl_ES.ISO8859-1',
  868.         'gl_es.iso885915':               'gl_ES.ISO8859-15',
  869.         'gl_es.iso885915@euro':          'gl_ES.ISO8859-15',
  870.         'gl_es.utf8@euro':               'gl_ES.UTF-8',
  871.         'gl_es@euro':                    'gl_ES.ISO8859-15',
  872.         'greek':                         'el_GR.ISO8859-7',
  873.         'greek.iso88597':                'el_GR.ISO8859-7',
  874.         'gv':                            'gv_GB.ISO8859-1',
  875.         'gv_gb':                         'gv_GB.ISO8859-1',
  876.         'gv_gb.iso88591':                'gv_GB.ISO8859-1',
  877.         'gv_gb.iso885914':               'gv_GB.ISO8859-14',
  878.         'gv_gb.iso885915':               'gv_GB.ISO8859-15',
  879.         'he':                            'he_IL.ISO8859-8',
  880.         'he_il':                         'he_IL.ISO8859-8',
  881.         'he_il.cp1255':                  'he_IL.CP1255',
  882.         'he_il.iso88598':                'he_IL.ISO8859-8',
  883.         'he_il.microsoftcp1255':         'he_IL.CP1255',
  884.         'hebrew':                        'iw_IL.ISO8859-8',
  885.         'hebrew.iso88598':               'iw_IL.ISO8859-8',
  886.         'hi':                            'hi_IN.ISCII-DEV',
  887.         'hi_in':                         'hi_IN.ISCII-DEV',
  888.         'hi_in.isciidev':                'hi_IN.ISCII-DEV',
  889.         'hr':                            'hr_HR.ISO8859-2',
  890.         'hr_hr':                         'hr_HR.ISO8859-2',
  891.         'hr_hr.iso88592':                'hr_HR.ISO8859-2',
  892.         'hrvatski':                      'hr_HR.ISO8859-2',
  893.         'hu':                            'hu_HU.ISO8859-2',
  894.         'hu_hu':                         'hu_HU.ISO8859-2',
  895.         'hu_hu.iso88592':                'hu_HU.ISO8859-2',
  896.         'hungarian':                     'hu_HU.ISO8859-2',
  897.         'icelandic':                     'is_IS.ISO8859-1',
  898.         'icelandic.iso88591':            'is_IS.ISO8859-1',
  899.         'id':                            'id_ID.ISO8859-1',
  900.         'id_id':                         'id_ID.ISO8859-1',
  901.         'in':                            'id_ID.ISO8859-1',
  902.         'in_id':                         'id_ID.ISO8859-1',
  903.         'is':                            'is_IS.ISO8859-1',
  904.         'is_is':                         'is_IS.ISO8859-1',
  905.         'is_is.iso88591':                'is_IS.ISO8859-1',
  906.         'is_is.iso885915':               'is_IS.ISO8859-15',
  907.         'iso-8859-1':                    'en_US.ISO8859-1',
  908.         'iso-8859-15':                   'en_US.ISO8859-15',
  909.         'iso8859-1':                     'en_US.ISO8859-1',
  910.         'iso8859-15':                    'en_US.ISO8859-15',
  911.         'iso_8859_1':                    'en_US.ISO8859-1',
  912.         'iso_8859_15':                   'en_US.ISO8859-15',
  913.         'it':                            'it_IT.ISO8859-1',
  914.         'it_ch':                         'it_CH.ISO8859-1',
  915.         'it_ch.iso88591':                'it_CH.ISO8859-1',
  916.         'it_ch.iso885915':               'it_CH.ISO8859-15',
  917.         'it_it':                         'it_IT.ISO8859-1',
  918.         'it_it.88591':                   'it_IT.ISO8859-1',
  919.         'it_it.iso88591':                'it_IT.ISO8859-1',
  920.         'it_it.iso885915':               'it_IT.ISO8859-15',
  921.         'it_it.iso885915@euro':          'it_IT.ISO8859-15',
  922.         'it_it.utf8@euro':               'it_IT.UTF-8',
  923.         'it_it@euro':                    'it_IT.ISO8859-15',
  924.         'italian':                       'it_IT.ISO8859-1',
  925.         'italian.iso88591':              'it_IT.ISO8859-1',
  926.         'iu':                            'iu_CA.NUNACOM-8',
  927.         'iu_ca':                         'iu_CA.NUNACOM-8',
  928.         'iu_ca.nunacom8':                'iu_CA.NUNACOM-8',
  929.         'iw':                            'he_IL.ISO8859-8',
  930.         'iw_il':                         'he_IL.ISO8859-8',
  931.         'iw_il.iso88598':                'he_IL.ISO8859-8',
  932.         'ja':                            'ja_JP.eucJP',
  933.         'ja.jis':                        'ja_JP.JIS7',
  934.         'ja.sjis':                       'ja_JP.SJIS',
  935.         'ja_jp':                         'ja_JP.eucJP',
  936.         'ja_jp.ajec':                    'ja_JP.eucJP',
  937.         'ja_jp.euc':                     'ja_JP.eucJP',
  938.         'ja_jp.eucjp':                   'ja_JP.eucJP',
  939.         'ja_jp.iso-2022-jp':             'ja_JP.JIS7',
  940.         'ja_jp.iso2022jp':               'ja_JP.JIS7',
  941.         'ja_jp.jis':                     'ja_JP.JIS7',
  942.         'ja_jp.jis7':                    'ja_JP.JIS7',
  943.         'ja_jp.mscode':                  'ja_JP.SJIS',
  944.         'ja_jp.sjis':                    'ja_JP.SJIS',
  945.         'ja_jp.ujis':                    'ja_JP.eucJP',
  946.         'japan':                         'ja_JP.eucJP',
  947.         'japanese':                      'ja_JP.eucJP',
  948.         'japanese-euc':                  'ja_JP.eucJP',
  949.         'japanese.euc':                  'ja_JP.eucJP',
  950.         'japanese.sjis':                 'ja_JP.SJIS',
  951.         'jp_jp':                         'ja_JP.eucJP',
  952.         'ka':                            'ka_GE.GEORGIAN-ACADEMY',
  953.         'ka_ge':                         'ka_GE.GEORGIAN-ACADEMY',
  954.         'ka_ge.georgianacademy':         'ka_GE.GEORGIAN-ACADEMY',
  955.         'ka_ge.georgianps':              'ka_GE.GEORGIAN-PS',
  956.         'ka_ge.georgianrs':              'ka_GE.GEORGIAN-ACADEMY',
  957.         'kl':                            'kl_GL.ISO8859-1',
  958.         'kl_gl':                         'kl_GL.ISO8859-1',
  959.         'kl_gl.iso88591':                'kl_GL.ISO8859-1',
  960.         'kl_gl.iso885915':               'kl_GL.ISO8859-15',
  961.         'ko':                            'ko_KR.eucKR',
  962.         'ko_kr':                         'ko_KR.eucKR',
  963.         'ko_kr.euc':                     'ko_KR.eucKR',
  964.         'ko_kr.euckr':                   'ko_KR.eucKR',
  965.         'korean':                        'ko_KR.eucKR',
  966.         'korean.euc':                    'ko_KR.eucKR',
  967.         'kw':                            'kw_GB.ISO8859-1',
  968.         'kw_gb':                         'kw_GB.ISO8859-1',
  969.         'kw_gb.iso88591':                'kw_GB.ISO8859-1',
  970.         'kw_gb.iso885914':               'kw_GB.ISO8859-14',
  971.         'kw_gb.iso885915':               'kw_GB.ISO8859-15',
  972.         'ky':                            'ky_KG.UTF-8',
  973.         'ky_kg':                         'ky_KG.UTF-8',
  974.         'lithuanian':                    'lt_LT.ISO8859-13',
  975.         'lo':                            'lo_LA.MULELAO-1',
  976.         'lo_la':                         'lo_LA.MULELAO-1',
  977.         'lo_la.cp1133':                  'lo_LA.IBM-CP1133',
  978.         'lo_la.ibmcp1133':               'lo_LA.IBM-CP1133',
  979.         'lo_la.mulelao1':                'lo_LA.MULELAO-1',
  980.         'lt':                            'lt_LT.ISO8859-13',
  981.         'lt_lt':                         'lt_LT.ISO8859-13',
  982.         'lt_lt.iso885913':               'lt_LT.ISO8859-13',
  983.         'lt_lt.iso88594':                'lt_LT.ISO8859-4',
  984.         'lv':                            'lv_LV.ISO8859-13',
  985.         'lv_lv':                         'lv_LV.ISO8859-13',
  986.         'lv_lv.iso885913':               'lv_LV.ISO8859-13',
  987.         'lv_lv.iso88594':                'lv_LV.ISO8859-4',
  988.         'mi':                            'mi_NZ.ISO8859-1',
  989.         'mi_nz':                         'mi_NZ.ISO8859-1',
  990.         'mi_nz.iso88591':                'mi_NZ.ISO8859-1',
  991.         'mk':                            'mk_MK.ISO8859-5',
  992.         'mk_mk':                         'mk_MK.ISO8859-5',
  993.         'mk_mk.cp1251':                  'mk_MK.CP1251',
  994.         'mk_mk.iso88595':                'mk_MK.ISO8859-5',
  995.         'mk_mk.microsoftcp1251':         'mk_MK.CP1251',
  996.         'mr_in':                         'mr_IN.UTF-8',
  997.         'ms':                            'ms_MY.ISO8859-1',
  998.         'ms_my':                         'ms_MY.ISO8859-1',
  999.         'ms_my.iso88591':                'ms_MY.ISO8859-1',
  1000.         'mt':                            'mt_MT.ISO8859-3',
  1001.         'mt_mt':                         'mt_MT.ISO8859-3',
  1002.         'mt_mt.iso88593':                'mt_MT.ISO8859-3',
  1003.         'nb':                            'nb_NO.ISO8859-1',
  1004.         'nb_no':                         'nb_NO.ISO8859-1',
  1005.         'nb_no.88591':                   'nb_NO.ISO8859-1',
  1006.         'nb_no.iso88591':                'nb_NO.ISO8859-1',
  1007.         'nb_no.iso885915':               'nb_NO.ISO8859-15',
  1008.         'nl':                            'nl_NL.ISO8859-1',
  1009.         'nl_be':                         'nl_BE.ISO8859-1',
  1010.         'nl_be.88591':                   'nl_BE.ISO8859-1',
  1011.         'nl_be.iso88591':                'nl_BE.ISO8859-1',
  1012.         'nl_be.iso885915':               'nl_BE.ISO8859-15',
  1013.         'nl_be.iso885915@euro':          'nl_BE.ISO8859-15',
  1014.         'nl_be.utf8@euro':               'nl_BE.UTF-8',
  1015.         'nl_be@euro':                    'nl_BE.ISO8859-15',
  1016.         'nl_nl':                         'nl_NL.ISO8859-1',
  1017.         'nl_nl.88591':                   'nl_NL.ISO8859-1',
  1018.         'nl_nl.iso88591':                'nl_NL.ISO8859-1',
  1019.         'nl_nl.iso885915':               'nl_NL.ISO8859-15',
  1020.         'nl_nl.iso885915@euro':          'nl_NL.ISO8859-15',
  1021.         'nl_nl.utf8@euro':               'nl_NL.UTF-8',
  1022.         'nl_nl@euro':                    'nl_NL.ISO8859-15',
  1023.         'nn':                            'nn_NO.ISO8859-1',
  1024.         'nn_no':                         'nn_NO.ISO8859-1',
  1025.         'nn_no.88591':                   'nn_NO.ISO8859-1',
  1026.         'nn_no.iso88591':                'nn_NO.ISO8859-1',
  1027.         'nn_no.iso885915':               'nn_NO.ISO8859-15',
  1028.         'no':                            'no_NO.ISO8859-1',
  1029.         'no@nynorsk':                    'ny_NO.ISO8859-1',
  1030.         'no_no':                         'no_NO.ISO8859-1',
  1031.         'no_no.88591':                   'no_NO.ISO8859-1',
  1032.         'no_no.iso88591':                'no_NO.ISO8859-1',
  1033.         'no_no.iso885915':               'no_NO.ISO8859-15',
  1034.         'norwegian':                     'no_NO.ISO8859-1',
  1035.         'norwegian.iso88591':            'no_NO.ISO8859-1',
  1036.         'nr':                            'nr_ZA.ISO8859-1',
  1037.         'nr_za':                         'nr_ZA.ISO8859-1',
  1038.         'nr_za.iso88591':                'nr_ZA.ISO8859-1',
  1039.         'nso':                           'nso_ZA.ISO8859-15',
  1040.         'nso_za':                        'nso_ZA.ISO8859-15',
  1041.         'nso_za.iso885915':              'nso_ZA.ISO8859-15',
  1042.         'ny':                            'ny_NO.ISO8859-1',
  1043.         'ny_no':                         'ny_NO.ISO8859-1',
  1044.         'ny_no.88591':                   'ny_NO.ISO8859-1',
  1045.         'ny_no.iso88591':                'ny_NO.ISO8859-1',
  1046.         'ny_no.iso885915':               'ny_NO.ISO8859-15',
  1047.         'nynorsk':                       'nn_NO.ISO8859-1',
  1048.         'oc':                            'oc_FR.ISO8859-1',
  1049.         'oc_fr':                         'oc_FR.ISO8859-1',
  1050.         'oc_fr.iso88591':                'oc_FR.ISO8859-1',
  1051.         'oc_fr.iso885915':               'oc_FR.ISO8859-15',
  1052.         'oc_fr@euro':                    'oc_FR.ISO8859-15',
  1053.         'pd':                            'pd_US.ISO8859-1',
  1054.         'pd_de':                         'pd_DE.ISO8859-1',
  1055.         'pd_de.iso88591':                'pd_DE.ISO8859-1',
  1056.         'pd_de.iso885915':               'pd_DE.ISO8859-15',
  1057.         'pd_us':                         'pd_US.ISO8859-1',
  1058.         'pd_us.iso88591':                'pd_US.ISO8859-1',
  1059.         'pd_us.iso885915':               'pd_US.ISO8859-15',
  1060.         'ph':                            'ph_PH.ISO8859-1',
  1061.         'ph_ph':                         'ph_PH.ISO8859-1',
  1062.         'ph_ph.iso88591':                'ph_PH.ISO8859-1',
  1063.         'pl':                            'pl_PL.ISO8859-2',
  1064.         'pl_pl':                         'pl_PL.ISO8859-2',
  1065.         'pl_pl.iso88592':                'pl_PL.ISO8859-2',
  1066.         'polish':                        'pl_PL.ISO8859-2',
  1067.         'portuguese':                    'pt_PT.ISO8859-1',
  1068.         'portuguese.iso88591':           'pt_PT.ISO8859-1',
  1069.         'portuguese_brazil':             'pt_BR.ISO8859-1',
  1070.         'portuguese_brazil.8859':        'pt_BR.ISO8859-1',
  1071.         'posix':                         'C',
  1072.         'posix-utf2':                    'C',
  1073.         'pp':                            'pp_AN.ISO8859-1',
  1074.         'pp_an':                         'pp_AN.ISO8859-1',
  1075.         'pp_an.iso88591':                'pp_AN.ISO8859-1',
  1076.         'pt':                            'pt_PT.ISO8859-1',
  1077.         'pt_br':                         'pt_BR.ISO8859-1',
  1078.         'pt_br.88591':                   'pt_BR.ISO8859-1',
  1079.         'pt_br.iso88591':                'pt_BR.ISO8859-1',
  1080.         'pt_br.iso885915':               'pt_BR.ISO8859-15',
  1081.         'pt_pt':                         'pt_PT.ISO8859-1',
  1082.         'pt_pt.88591':                   'pt_PT.ISO8859-1',
  1083.         'pt_pt.iso88591':                'pt_PT.ISO8859-1',
  1084.         'pt_pt.iso885915':               'pt_PT.ISO8859-15',
  1085.         'pt_pt.iso885915@euro':          'pt_PT.ISO8859-15',
  1086.         'pt_pt.utf8@euro':               'pt_PT.UTF-8',
  1087.         'pt_pt@euro':                    'pt_PT.ISO8859-15',
  1088.         'ro':                            'ro_RO.ISO8859-2',
  1089.         'ro_ro':                         'ro_RO.ISO8859-2',
  1090.         'ro_ro.iso88592':                'ro_RO.ISO8859-2',
  1091.         'romanian':                      'ro_RO.ISO8859-2',
  1092.         'ru':                            'ru_RU.ISO8859-5',
  1093.         'ru_ru':                         'ru_RU.ISO8859-5',
  1094.         'ru_ru.cp1251':                  'ru_RU.CP1251',
  1095.         'ru_ru.iso88595':                'ru_RU.ISO8859-5',
  1096.         'ru_ru.koi8r':                   'ru_RU.KOI8-R',
  1097.         'ru_ru.microsoftcp1251':         'ru_RU.CP1251',
  1098.         'ru_ua':                         'ru_UA.KOI8-U',
  1099.         'ru_ua.cp1251':                  'ru_UA.CP1251',
  1100.         'ru_ua.koi8u':                   'ru_UA.KOI8-U',
  1101.         'ru_ua.microsoftcp1251':         'ru_UA.CP1251',
  1102.         'rumanian':                      'ro_RO.ISO8859-2',
  1103.         'russian':                       'ru_RU.ISO8859-5',
  1104.         'rw':                            'rw_RW.ISO8859-1',
  1105.         'rw_rw':                         'rw_RW.ISO8859-1',
  1106.         'rw_rw.iso88591':                'rw_RW.ISO8859-1',
  1107.         'se_no':                         'se_NO.UTF-8',
  1108.         'serbocroatian':                 'sh_YU.ISO8859-2',
  1109.         'sh':                            'sh_YU.ISO8859-2',
  1110.         'sh_hr':                         'sh_HR.ISO8859-2',
  1111.         'sh_hr.iso88592':                'sh_HR.ISO8859-2',
  1112.         'sh_sp':                         'sh_YU.ISO8859-2',
  1113.         'sh_yu':                         'sh_YU.ISO8859-2',
  1114.         'si':                            'si_LK.UTF-8',
  1115.         'si_lk':                         'si_LK.UTF-8',
  1116.         'sinhala':                       'si_LK.UTF-8',
  1117.         'sk':                            'sk_SK.ISO8859-2',
  1118.         'sk_sk':                         'sk_SK.ISO8859-2',
  1119.         'sk_sk.iso88592':                'sk_SK.ISO8859-2',
  1120.         'sl':                            'sl_SI.ISO8859-2',
  1121.         'sl_cs':                         'sl_CS.ISO8859-2',
  1122.         'sl_si':                         'sl_SI.ISO8859-2',
  1123.         'sl_si.iso88592':                'sl_SI.ISO8859-2',
  1124.         'slovak':                        'sk_SK.ISO8859-2',
  1125.         'slovene':                       'sl_SI.ISO8859-2',
  1126.         'slovenian':                     'sl_SI.ISO8859-2',
  1127.         'sp':                            'sp_YU.ISO8859-5',
  1128.         'sp_yu':                         'sp_YU.ISO8859-5',
  1129.         'spanish':                       'es_ES.ISO8859-1',
  1130.         'spanish.iso88591':              'es_ES.ISO8859-1',
  1131.         'spanish_spain':                 'es_ES.ISO8859-1',
  1132.         'spanish_spain.8859':            'es_ES.ISO8859-1',
  1133.         'sq':                            'sq_AL.ISO8859-2',
  1134.         'sq_al':                         'sq_AL.ISO8859-2',
  1135.         'sq_al.iso88592':                'sq_AL.ISO8859-2',
  1136.         'sr':                            'sr_YU.ISO8859-5',
  1137.         'sr@cyrillic':                   'sr_YU.ISO8859-5',
  1138.         'sr_sp':                         'sr_SP.ISO8859-2',
  1139.         'sr_yu':                         'sr_YU.ISO8859-5',
  1140.         'sr_yu.cp1251@cyrillic':         'sr_YU.CP1251',
  1141.         'sr_yu.iso88592':                'sr_YU.ISO8859-2',
  1142.         'sr_yu.iso88595':                'sr_YU.ISO8859-5',
  1143.         'sr_yu.iso88595@cyrillic':       'sr_YU.ISO8859-5',
  1144.         'sr_yu.microsoftcp1251@cyrillic':'sr_YU.CP1251',
  1145.         'sr_yu.utf8@cyrillic':           'sr_YU.UTF-8',
  1146.         'sr_yu@cyrillic':                'sr_YU.ISO8859-5',
  1147.         'ss':                            'ss_ZA.ISO8859-1',
  1148.         'ss_za':                         'ss_ZA.ISO8859-1',
  1149.         'ss_za.iso88591':                'ss_ZA.ISO8859-1',
  1150.         'st':                            'st_ZA.ISO8859-1',
  1151.         'st_za':                         'st_ZA.ISO8859-1',
  1152.         'st_za.iso88591':                'st_ZA.ISO8859-1',
  1153.         'sv':                            'sv_SE.ISO8859-1',
  1154.         'sv_fi':                         'sv_FI.ISO8859-1',
  1155.         'sv_fi.iso88591':                'sv_FI.ISO8859-1',
  1156.         'sv_fi.iso885915':               'sv_FI.ISO8859-15',
  1157.         'sv_fi.iso885915@euro':          'sv_FI.ISO8859-15',
  1158.         'sv_fi.utf8@euro':               'sv_FI.UTF-8',
  1159.         'sv_fi@euro':                    'sv_FI.ISO8859-15',
  1160.         'sv_se':                         'sv_SE.ISO8859-1',
  1161.         'sv_se.88591':                   'sv_SE.ISO8859-1',
  1162.         'sv_se.iso88591':                'sv_SE.ISO8859-1',
  1163.         'sv_se.iso885915':               'sv_SE.ISO8859-15',
  1164.         'sv_se@euro':                    'sv_SE.ISO8859-15',
  1165.         'swedish':                       'sv_SE.ISO8859-1',
  1166.         'swedish.iso88591':              'sv_SE.ISO8859-1',
  1167.         'ta':                            'ta_IN.TSCII-0',
  1168.         'ta_in':                         'ta_IN.TSCII-0',
  1169.         'ta_in.tscii':                   'ta_IN.TSCII-0',
  1170.         'ta_in.tscii0':                  'ta_IN.TSCII-0',
  1171.         'tg':                            'tg_TJ.KOI8-C',
  1172.         'tg_tj':                         'tg_TJ.KOI8-C',
  1173.         'tg_tj.koi8c':                   'tg_TJ.KOI8-C',
  1174.         'th':                            'th_TH.ISO8859-11',
  1175.         'th_th':                         'th_TH.ISO8859-11',
  1176.         'th_th.iso885911':               'th_TH.ISO8859-11',
  1177.         'th_th.tactis':                  'th_TH.TIS620',
  1178.         'th_th.tis620':                  'th_TH.TIS620',
  1179.         'thai':                          'th_TH.ISO8859-11',
  1180.         'tl':                            'tl_PH.ISO8859-1',
  1181.         'tl_ph':                         'tl_PH.ISO8859-1',
  1182.         'tl_ph.iso88591':                'tl_PH.ISO8859-1',
  1183.         'tn':                            'tn_ZA.ISO8859-15',
  1184.         'tn_za':                         'tn_ZA.ISO8859-15',
  1185.         'tn_za.iso885915':               'tn_ZA.ISO8859-15',
  1186.         'tr':                            'tr_TR.ISO8859-9',
  1187.         'tr_tr':                         'tr_TR.ISO8859-9',
  1188.         'tr_tr.iso88599':                'tr_TR.ISO8859-9',
  1189.         'ts':                            'ts_ZA.ISO8859-1',
  1190.         'ts_za':                         'ts_ZA.ISO8859-1',
  1191.         'ts_za.iso88591':                'ts_ZA.ISO8859-1',
  1192.         'tt':                            'tt_RU.TATAR-CYR',
  1193.         'tt_ru':                         'tt_RU.TATAR-CYR',
  1194.         'tt_ru.koi8c':                   'tt_RU.KOI8-C',
  1195.         'tt_ru.tatarcyr':                'tt_RU.TATAR-CYR',
  1196.         'turkish':                       'tr_TR.ISO8859-9',
  1197.         'turkish.iso88599':              'tr_TR.ISO8859-9',
  1198.         'uk':                            'uk_UA.KOI8-U',
  1199.         'uk_ua':                         'uk_UA.KOI8-U',
  1200.         'uk_ua.cp1251':                  'uk_UA.CP1251',
  1201.         'uk_ua.iso88595':                'uk_UA.ISO8859-5',
  1202.         'uk_ua.koi8u':                   'uk_UA.KOI8-U',
  1203.         'uk_ua.microsoftcp1251':         'uk_UA.CP1251',
  1204.         'univ':                          'en_US.utf-8',
  1205.         'universal':                     'en_US.utf-8',
  1206.         'universal.utf8@ucs4':           'en_US.UTF-8',
  1207.         'ur':                            'ur_PK.CP1256',
  1208.         'ur_pk':                         'ur_PK.CP1256',
  1209.         'ur_pk.cp1256':                  'ur_PK.CP1256',
  1210.         'ur_pk.microsoftcp1256':         'ur_PK.CP1256',
  1211.         'uz':                            'uz_UZ.UTF-8',
  1212.         'uz_uz':                         'uz_UZ.UTF-8',
  1213.         'uz_uz.iso88591':                'uz_UZ.ISO8859-1',
  1214.         'uz_uz.utf8@cyrillic':           'uz_UZ.UTF-8',
  1215.         'uz_uz@cyrillic':                'uz_UZ.UTF-8',
  1216.         've':                            've_ZA.UTF-8',
  1217.         've_za':                         've_ZA.UTF-8',
  1218.         'vi':                            'vi_VN.TCVN',
  1219.         'vi_vn':                         'vi_VN.TCVN',
  1220.         'vi_vn.tcvn':                    'vi_VN.TCVN',
  1221.         'vi_vn.tcvn5712':                'vi_VN.TCVN',
  1222.         'vi_vn.viscii':                  'vi_VN.VISCII',
  1223.         'vi_vn.viscii111':               'vi_VN.VISCII',
  1224.         'wa':                            'wa_BE.ISO8859-1',
  1225.         'wa_be':                         'wa_BE.ISO8859-1',
  1226.         'wa_be.iso88591':                'wa_BE.ISO8859-1',
  1227.         'wa_be.iso885915':               'wa_BE.ISO8859-15',
  1228.         'wa_be.iso885915@euro':          'wa_BE.ISO8859-15',
  1229.         'wa_be@euro':                    'wa_BE.ISO8859-15',
  1230.         'xh':                            'xh_ZA.ISO8859-1',
  1231.         'xh_za':                         'xh_ZA.ISO8859-1',
  1232.         'xh_za.iso88591':                'xh_ZA.ISO8859-1',
  1233.         'yi':                            'yi_US.CP1255',
  1234.         'yi_us':                         'yi_US.CP1255',
  1235.         'yi_us.cp1255':                  'yi_US.CP1255',
  1236.         'yi_us.microsoftcp1255':         'yi_US.CP1255',
  1237.         'zh':                            'zh_CN.eucCN',
  1238.         'zh_cn':                         'zh_CN.gb2312',
  1239.         'zh_cn.big5':                    'zh_TW.big5',
  1240.         'zh_cn.euc':                     'zh_CN.eucCN',
  1241.         'zh_cn.gb18030':                 'zh_CN.gb18030',
  1242.         'zh_cn.gb2312':                  'zh_CN.gb2312',
  1243.         'zh_cn.gbk':                     'zh_CN.gbk',
  1244.         'zh_hk':                         'zh_HK.big5hkscs',
  1245.         'zh_hk.big5':                    'zh_HK.big5',
  1246.         'zh_hk.big5hkscs':               'zh_HK.big5hkscs',
  1247.         'zh_tw':                         'zh_TW.big5',
  1248.         'zh_tw.big5':                    'zh_TW.big5',
  1249.         'zh_tw.euc':                     'zh_TW.eucTW',
  1250.         'zh_tw.euctw':                   'zh_TW.eucTW',
  1251.         'zu':                            'zu_ZA.ISO8859-1',
  1252.         'zu_za':                         'zu_ZA.ISO8859-1',
  1253.         'zu_za.iso88591':                'zu_ZA.ISO8859-1',
  1254. }
  1255.  
  1256. #
  1257. # This maps Windows language identifiers to locale strings.
  1258. #
  1259. # This list has been updated from
  1260. # http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_238z.asp
  1261. # to include every locale up to Windows XP.
  1262. #
  1263. # NOTE: this mapping is incomplete.  If your language is missing, please
  1264. # submit a bug report to Python bug manager, which you can find via:
  1265. #     http://www.python.org/dev/
  1266. # Make sure you include the missing language identifier and the suggested
  1267. # locale code.
  1268. #
  1269.  
  1270. windows_locale = {
  1271.     0x0436: "af_ZA", # Afrikaans
  1272.     0x041c: "sq_AL", # Albanian
  1273.     0x0401: "ar_SA", # Arabic - Saudi Arabia
  1274.     0x0801: "ar_IQ", # Arabic - Iraq
  1275.     0x0c01: "ar_EG", # Arabic - Egypt
  1276.     0x1001: "ar_LY", # Arabic - Libya
  1277.     0x1401: "ar_DZ", # Arabic - Algeria
  1278.     0x1801: "ar_MA", # Arabic - Morocco
  1279.     0x1c01: "ar_TN", # Arabic - Tunisia
  1280.     0x2001: "ar_OM", # Arabic - Oman
  1281.     0x2401: "ar_YE", # Arabic - Yemen
  1282.     0x2801: "ar_SY", # Arabic - Syria
  1283.     0x2c01: "ar_JO", # Arabic - Jordan
  1284.     0x3001: "ar_LB", # Arabic - Lebanon
  1285.     0x3401: "ar_KW", # Arabic - Kuwait
  1286.     0x3801: "ar_AE", # Arabic - United Arab Emirates
  1287.     0x3c01: "ar_BH", # Arabic - Bahrain
  1288.     0x4001: "ar_QA", # Arabic - Qatar
  1289.     0x042b: "hy_AM", # Armenian
  1290.     0x042c: "az_AZ", # Azeri Latin
  1291.     0x082c: "az_AZ", # Azeri - Cyrillic
  1292.     0x042d: "eu_ES", # Basque
  1293.     0x0423: "be_BY", # Belarusian
  1294.     0x0445: "bn_IN", # Begali
  1295.     0x201a: "bs_BA", # Bosnian
  1296.     0x141a: "bs_BA", # Bosnian - Cyrillic
  1297.     0x047e: "br_FR", # Breton - France
  1298.     0x0402: "bg_BG", # Bulgarian
  1299.     0x0403: "ca_ES", # Catalan
  1300.     0x0004: "zh_CHS",# Chinese - Simplified
  1301.     0x0404: "zh_TW", # Chinese - Taiwan
  1302.     0x0804: "zh_CN", # Chinese - PRC
  1303.     0x0c04: "zh_HK", # Chinese - Hong Kong S.A.R.
  1304.     0x1004: "zh_SG", # Chinese - Singapore
  1305.     0x1404: "zh_MO", # Chinese - Macao S.A.R.
  1306.     0x7c04: "zh_CHT",# Chinese - Traditional
  1307.     0x041a: "hr_HR", # Croatian
  1308.     0x101a: "hr_BA", # Croatian - Bosnia
  1309.     0x0405: "cs_CZ", # Czech
  1310.     0x0406: "da_DK", # Danish
  1311.     0x048c: "gbz_AF",# Dari - Afghanistan
  1312.     0x0465: "div_MV",# Divehi - Maldives
  1313.     0x0413: "nl_NL", # Dutch - The Netherlands
  1314.     0x0813: "nl_BE", # Dutch - Belgium
  1315.     0x0409: "en_US", # English - United States
  1316.     0x0809: "en_GB", # English - United Kingdom
  1317.     0x0c09: "en_AU", # English - Australia
  1318.     0x1009: "en_CA", # English - Canada
  1319.     0x1409: "en_NZ", # English - New Zealand
  1320.     0x1809: "en_IE", # English - Ireland
  1321.     0x1c09: "en_ZA", # English - South Africa
  1322.     0x2009: "en_JA", # English - Jamaica
  1323.     0x2409: "en_CB", # English - Carribbean
  1324.     0x2809: "en_BZ", # English - Belize
  1325.     0x2c09: "en_TT", # English - Trinidad
  1326.     0x3009: "en_ZW", # English - Zimbabwe
  1327.     0x3409: "en_PH", # English - Phillippines
  1328.     0x0425: "et_EE", # Estonian
  1329.     0x0438: "fo_FO", # Faroese
  1330.     0x0464: "fil_PH",# Filipino
  1331.     0x040b: "fi_FI", # Finnish
  1332.     0x040c: "fr_FR", # French - France
  1333.     0x080c: "fr_BE", # French - Belgium
  1334.     0x0c0c: "fr_CA", # French - Canada
  1335.     0x100c: "fr_CH", # French - Switzerland
  1336.     0x140c: "fr_LU", # French - Luxembourg
  1337.     0x180c: "fr_MC", # French - Monaco
  1338.     0x0462: "fy_NL", # Frisian - Netherlands
  1339.     0x0456: "gl_ES", # Galician
  1340.     0x0437: "ka_GE", # Georgian
  1341.     0x0407: "de_DE", # German - Germany
  1342.     0x0807: "de_CH", # German - Switzerland
  1343.     0x0c07: "de_AT", # German - Austria
  1344.     0x1007: "de_LU", # German - Luxembourg
  1345.     0x1407: "de_LI", # German - Liechtenstein
  1346.     0x0408: "el_GR", # Greek
  1347.     0x0447: "gu_IN", # Gujarati
  1348.     0x040d: "he_IL", # Hebrew
  1349.     0x0439: "hi_IN", # Hindi
  1350.     0x040e: "hu_HU", # Hungarian
  1351.     0x040f: "is_IS", # Icelandic
  1352.     0x0421: "id_ID", # Indonesian
  1353.     0x045d: "iu_CA", # Inuktitut
  1354.     0x085d: "iu_CA", # Inuktitut - Latin
  1355.     0x083c: "ga_IE", # Irish - Ireland
  1356.     0x0434: "xh_ZA", # Xhosa - South Africa
  1357.     0x0435: "zu_ZA", # Zulu
  1358.     0x0410: "it_IT", # Italian - Italy
  1359.     0x0810: "it_CH", # Italian - Switzerland
  1360.     0x0411: "ja_JP", # Japanese
  1361.     0x044b: "kn_IN", # Kannada - India
  1362.     0x043f: "kk_KZ", # Kazakh
  1363.     0x0457: "kok_IN",# Konkani
  1364.     0x0412: "ko_KR", # Korean
  1365.     0x0440: "ky_KG", # Kyrgyz
  1366.     0x0426: "lv_LV", # Latvian
  1367.     0x0427: "lt_LT", # Lithuanian
  1368.     0x046e: "lb_LU", # Luxembourgish
  1369.     0x042f: "mk_MK", # FYRO Macedonian
  1370.     0x043e: "ms_MY", # Malay - Malaysia
  1371.     0x083e: "ms_BN", # Malay - Brunei
  1372.     0x044c: "ml_IN", # Malayalam - India
  1373.     0x043a: "mt_MT", # Maltese
  1374.     0x0481: "mi_NZ", # Maori
  1375.     0x047a: "arn_CL",# Mapudungun
  1376.     0x044e: "mr_IN", # Marathi
  1377.     0x047c: "moh_CA",# Mohawk - Canada
  1378.     0x0450: "mn_MN", # Mongolian
  1379.     0x0461: "ne_NP", # Nepali
  1380.     0x0414: "nb_NO", # Norwegian - Bokmal
  1381.     0x0814: "nn_NO", # Norwegian - Nynorsk
  1382.     0x0482: "oc_FR", # Occitan - France
  1383.     0x0448: "or_IN", # Oriya - India
  1384.     0x0463: "ps_AF", # Pashto - Afghanistan
  1385.     0x0429: "fa_IR", # Persian
  1386.     0x0415: "pl_PL", # Polish
  1387.     0x0416: "pt_BR", # Portuguese - Brazil
  1388.     0x0816: "pt_PT", # Portuguese - Portugal
  1389.     0x0446: "pa_IN", # Punjabi
  1390.     0x046b: "quz_BO",# Quechua (Bolivia)
  1391.     0x086b: "quz_EC",# Quechua (Ecuador)
  1392.     0x0c6b: "quz_PE",# Quechua (Peru)
  1393.     0x0418: "ro_RO", # Romanian - Romania
  1394.     0x0417: "rm_CH", # Raeto-Romanese
  1395.     0x0419: "ru_RU", # Russian
  1396.     0x243b: "smn_FI",# Sami Finland
  1397.     0x103b: "smj_NO",# Sami Norway
  1398.     0x143b: "smj_SE",# Sami Sweden
  1399.     0x043b: "se_NO", # Sami Northern Norway
  1400.     0x083b: "se_SE", # Sami Northern Sweden
  1401.     0x0c3b: "se_FI", # Sami Northern Finland
  1402.     0x203b: "sms_FI",# Sami Skolt
  1403.     0x183b: "sma_NO",# Sami Southern Norway
  1404.     0x1c3b: "sma_SE",# Sami Southern Sweden
  1405.     0x044f: "sa_IN", # Sanskrit
  1406.     0x0c1a: "sr_SP", # Serbian - Cyrillic
  1407.     0x1c1a: "sr_BA", # Serbian - Bosnia Cyrillic
  1408.     0x081a: "sr_SP", # Serbian - Latin
  1409.     0x181a: "sr_BA", # Serbian - Bosnia Latin
  1410.     0x046c: "ns_ZA", # Northern Sotho
  1411.     0x0432: "tn_ZA", # Setswana - Southern Africa
  1412.     0x041b: "sk_SK", # Slovak
  1413.     0x0424: "sl_SI", # Slovenian
  1414.     0x040a: "es_ES", # Spanish - Spain
  1415.     0x080a: "es_MX", # Spanish - Mexico
  1416.     0x0c0a: "es_ES", # Spanish - Spain (Modern)
  1417.     0x100a: "es_GT", # Spanish - Guatemala
  1418.     0x140a: "es_CR", # Spanish - Costa Rica
  1419.     0x180a: "es_PA", # Spanish - Panama
  1420.     0x1c0a: "es_DO", # Spanish - Dominican Republic
  1421.     0x200a: "es_VE", # Spanish - Venezuela
  1422.     0x240a: "es_CO", # Spanish - Colombia
  1423.     0x280a: "es_PE", # Spanish - Peru
  1424.     0x2c0a: "es_AR", # Spanish - Argentina
  1425.     0x300a: "es_EC", # Spanish - Ecuador
  1426.     0x340a: "es_CL", # Spanish - Chile
  1427.     0x380a: "es_UR", # Spanish - Uruguay
  1428.     0x3c0a: "es_PY", # Spanish - Paraguay
  1429.     0x400a: "es_BO", # Spanish - Bolivia
  1430.     0x440a: "es_SV", # Spanish - El Salvador
  1431.     0x480a: "es_HN", # Spanish - Honduras
  1432.     0x4c0a: "es_NI", # Spanish - Nicaragua
  1433.     0x500a: "es_PR", # Spanish - Puerto Rico
  1434.     0x0441: "sw_KE", # Swahili
  1435.     0x041d: "sv_SE", # Swedish - Sweden
  1436.     0x081d: "sv_FI", # Swedish - Finland
  1437.     0x045a: "syr_SY",# Syriac
  1438.     0x0449: "ta_IN", # Tamil
  1439.     0x0444: "tt_RU", # Tatar
  1440.     0x044a: "te_IN", # Telugu
  1441.     0x041e: "th_TH", # Thai
  1442.     0x041f: "tr_TR", # Turkish
  1443.     0x0422: "uk_UA", # Ukrainian
  1444.     0x0420: "ur_PK", # Urdu
  1445.     0x0820: "ur_IN", # Urdu - India
  1446.     0x0443: "uz_UZ", # Uzbek - Latin
  1447.     0x0843: "uz_UZ", # Uzbek - Cyrillic
  1448.     0x042a: "vi_VN", # Vietnamese
  1449.     0x0452: "cy_GB", # Welsh
  1450. }
  1451.  
  1452. def _print_locale():
  1453.  
  1454.     """ Test function.
  1455.     """
  1456.     categories = {}
  1457.     def _init_categories(categories=categories):
  1458.         for k,v in globals().items():
  1459.             if k[:3] == 'LC_':
  1460.                 categories[k] = v
  1461.     _init_categories()
  1462.     del categories['LC_ALL']
  1463.  
  1464.     print 'Locale defaults as determined by getdefaultlocale():'
  1465.     print '-'*72
  1466.     lang, enc = getdefaultlocale()
  1467.     print 'Language: ', lang or '(undefined)'
  1468.     print 'Encoding: ', enc or '(undefined)'
  1469.     print
  1470.  
  1471.     print 'Locale settings on startup:'
  1472.     print '-'*72
  1473.     for name,category in categories.items():
  1474.         print name, '...'
  1475.         lang, enc = getlocale(category)
  1476.         print '   Language: ', lang or '(undefined)'
  1477.         print '   Encoding: ', enc or '(undefined)'
  1478.         print
  1479.  
  1480.     print
  1481.     print 'Locale settings after calling resetlocale():'
  1482.     print '-'*72
  1483.     resetlocale()
  1484.     for name,category in categories.items():
  1485.         print name, '...'
  1486.         lang, enc = getlocale(category)
  1487.         print '   Language: ', lang or '(undefined)'
  1488.         print '   Encoding: ', enc or '(undefined)'
  1489.         print
  1490.  
  1491.     try:
  1492.         setlocale(LC_ALL, "")
  1493.     except:
  1494.         print 'NOTE:'
  1495.         print 'setlocale(LC_ALL, "") does not support the default locale'
  1496.         print 'given in the OS environment variables.'
  1497.     else:
  1498.         print
  1499.         print 'Locale settings after calling setlocale(LC_ALL, ""):'
  1500.         print '-'*72
  1501.         for name,category in categories.items():
  1502.             print name, '...'
  1503.             lang, enc = getlocale(category)
  1504.             print '   Language: ', lang or '(undefined)'
  1505.             print '   Encoding: ', enc or '(undefined)'
  1506.             print
  1507.  
  1508. ###
  1509.  
  1510. try:
  1511.     LC_MESSAGES
  1512. except NameError:
  1513.     pass
  1514. else:
  1515.     __all__.append("LC_MESSAGES")
  1516.  
  1517. if __name__=='__main__':
  1518.     print 'Locale aliasing:'
  1519.     print
  1520.     _print_locale()
  1521.     print
  1522.     print 'Number formatting:'
  1523.     print
  1524.     _test()
  1525.